﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SemenQuest.SubWindows
{
    class CustomTrackBar : TrackBar
    {
        [DllImport("user32.dll", EntryPoint = "SendMessageW")]
        private extern static IntPtr SendMessageRect(IntPtr hWnd, Int32 msg, IntPtr wp, ref RECT lp);

        private struct RECT { public Int32 left, top, right, bottom;}
        private const Int32 TBM_GETCHANNELRECT = 0x400 + 26;
        private const Int32 TBM_GETTHUMBRECT = 0x400 + 25;

        public Rectangle Slider
        {
            get
            {
                RECT rc = new RECT();
                SendMessageRect(this.Handle, TBM_GETTHUMBRECT, IntPtr.Zero, ref rc);
                return new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
            }
        }
        public Rectangle Channel
        {
            get
            {
                RECT rc = new RECT();
                SendMessageRect(this.Handle, TBM_GETCHANNELRECT, IntPtr.Zero, ref rc);
                return new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
            }
        }

    }
}
